add JDK 9 support #143
add JDK 9 support #143
Conversation
${java_args[@]} \ | ||
-jar "$rtexport" \ | ||
"${java9_rt}" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will copy rt.jar only once. However, jdk 9 might be updated over time. People may select different versions for debugging reasons, or may flip from OpenJDK to Oracle's JDK, to IBM's JVM. That may cause unexpected behavior or crashes. Probably rt.jar should be copied on each startup; alternatively, the full version string could be dumped to a text file and matched upon startup, so that if it differs the rt.jar file is extracted again.
vlog "[process_args] java_version = '$java_version'" | ||
rtexport=$(rt_export_file) | ||
sbt_global_dir=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to move this out to copyRt so I can use this script from Java 1.6 and 1.7.
@eed3si9n you mentioned you were seeing a 1.8 java.version in the system property. Could you show what you did? I'm not seeing it:
|
Using the Scala 2.12.1 REPL:
|
The string used for versioning should include vendor, patch level, and all the details that may uniquely identify a given JVM release. Here are a few suggestions: http://stackoverflow.com/a/5103166
|
I did something along the lines of
compiled it using Java 8, and ran it on JDK 9, and I get this:
|
Here's a WIP commit - a2ee22e |
FWIW, rebasing that change on @retronym's original doesn't show what you're seeing: diff --git a/src/main/java/io/github/retronym/java9rtexport/Export.java b/src/main/java/io/github/retronym/java9rtexport/Export.java
index 5591dde..e5c2b41 100644
--- a/src/main/java/io/github/retronym/java9rtexport/Export.java
+++ b/src/main/java/io/github/retronym/java9rtexport/Export.java
@@ -10,6 +10,8 @@ import java.util.Map;
public class Export {
public static void main(String[] args) {
try {
+ final String v = System.getProperty("java.version");
+ System.out.println("java.version = " + v);
FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jrt:/"));
Path path = fileSystem.getPath("/modules");
String destination = args[0]; 10:58:32 $ jenv local 1.8
10:58:37 $ sbt clean package
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/0.13/plugins
[info] Loading project definition from /d/java9-rt-export/project
[info] Set current project to java9-rt-export (in build file:/d/java9-rt-export/)
[success] Total time: 0 s, completed 07-Mar-2017 10:58:50
[info] Updating {file:/d/java9-rt-export/}java9-rt-export...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 2 Java sources to /d/java9-rt-export/target/classes...
[info] Packaging /d/java9-rt-export/target/java9-rt-export-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 1 s, completed 07-Mar-2017 10:58:51
10:58:51 $ jenv local 9-ea
10:58:55 $ java -jar target/java9-rt-export-0.1-SNAPSHOT.jar rt.jar
java.version = 9-ea |
I can't reproduce what you're seeing. Using a2ee22e on your wip/jdk9_branch: 11:20:22 $ jenv local 1.8
11:20:26 $ sbt -Dsbt.build.version=1.0.0 java9rtexport/clean java9rtexport/package
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/0.13/plugins
[info] Loading project definition from /d/sbt-launcher-package/project/project
[info] Loading project definition from /d/sbt-launcher-package/project
[info] Set current project to sbt-launcher-packaging (in build file:/d/sbt-launcher-package/)
[success] Total time: 0 s, completed 07-Mar-2017 11:20:40
[info] Updating {file:/d/sbt-launcher-package/}java9rtexport...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 2 Java sources to /d/sbt-launcher-package/java9-rt-export/target/classes...
[info] Packaging /d/sbt-launcher-package/java9-rt-export/target/java9-rt-export-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 1 s, completed 07-Mar-2017 11:20:41
11:20:42 $ jenv local 9-ea
11:20:48 $ java -jar java9-rt-export/target/java9-rt-export-0.1-SNAPSHOT.jar --rt-ext-dir
/Users/dnw/.sbt/0.13/java9-rt-ext-9-ea Something's up with your setup maybe. |
I finally figured out the mystery. When I was running the following:
jenv was picking up |
So now that |
Vendor properties and values on my 9-ea installation (using jshell):
|
I would say a concatenation (with spaces/special characters remapped/removed) of these three, for the directory name:
|
For compiler bridge sbt currently just uses java.version as postfix. Maybe we can add |
@eed3si9n All right, LGTM. |
This copies https://github.com/retronym/java9-rt-export into this repository.
Next it improves the version detection script using sed.
When Java 9 is detected it uses java9-rt-export to evaluate the sbt's global base directory, and it copies the rt.jar off to the side, and starts sbt with
-Dscala.ext.dirs
flag as described in sbt/sbt#2951.For Windows, it uses a bit more primitive method of detecting the Java version since
sed
is not available by default.